user = [
    ["admin", "123456", 1],
    ["lisi", "123456", 2]
]

family = [
    ["类别", "账户", "金额", "时间", "说明"],
    ["吃饭支出", "交通银行", "247.0", "2016-03-02", "家庭聚餐"],
    ["工资收入", "现金", "12345.0", "2016-03-15", "开工资了"],
    ["服装支出", "现金", "1998.0", "2016-04-02", "买衣服"],
    ["吃饭支出", "现金", "325.0", "2016-06-18", "朋友聚餐"],
    ["股票收入", "工商银行", "8000.0", "2016-10-28", "股票大涨"],
    ["股票收入", "工商银行", "5000.0", "2016-10-28", "股票又大涨"],
    ["礼金支出", "现金", "5000.0", "2016-10-28", "朋友结婚"],
    ["工资收入", "现金", "1000.0", "2016-10-30", "开资"],
    ["工资收入", "现金", "5000.0", "2016-10-30", "又开资"]
]

type = 0
login_status = False
while True:
    name = None
    password = None
    if not login_status:
        print("欢迎登录度小满记账系统")
        name = input("请输入登录账号：")
        password = input("请输入密码：")
        for i in user:
            if i[0] == name and i[1] == password:
                type = i[2]
                break
        if type == 0:
            print("账号或密码错误，请重新输入")
            login_status = False
            continue
        else:
            login_status = True
            print("登录成功")
            #管理员
            if type == 1:
                while True:
                    print("1.添加账务        2.编辑账务        3.删除账务        4.查询账务        5.退出")
                    n=input("请输入要操作的功能序号[1-5]：")
                    if n == "5":
                        print("退出成功")
                        break
                    elif n == "4":
                        for i in range(0, len(family)):
                            zfc = ""
                            for j in range(0, len(family[i])):
                                zfc = zfc + "\t" + str(family[i][j])
                            print(i , zfc)
                            print("".center(50, "-"))
                    elif n == "3":
                        id = int(input("请输入ID："))
                        del family[id]
                        print("删除账务成功")
                    elif n == "2":
                        id = int(input("请选择要编辑的ID："))
                        # print(family[id])
                        m = int(input("请选择要编辑的序号：1.类别   2.账户  3.金额  4.时间  5.说明"))
                        s = input("请输入修改内容：")
                        family[id][m-1] = s
                        print(family[id])
                    elif n == "1":
                        list = []
                        list.append(input("请输入类别："))
                        list.append(input("请输入账户："))
                        list.append(input("请输入金额："))
                        list.append(input("请输入时间："))
                        list.append(input("请输入说明："))
                        family.append(list)
            #普通用户
            elif type == 2:
                while True:
                    print("1.查询所有        2.按条件查询")
                    chose = input("请选择：")
                    if chose == "1":
                        print("".center(50, "-"))
                        for i in range(0, len(family)):
                            zfc = ""
                            for j in range(0, len(family[i])):
                                zfc = zfc + "\t" + str(family[i][j])
                            print(i , zfc)
                            print("".center(50, "-"))
                        break
                    elif chose == "2":
                        print("1.ID        2.类别        3.账户        4.金额        5.时间")
                        ch = []
                        find = input("请输入查询条件：")
                        if find.isdigit():
                            if find == "1":
                                print("".center(50, "-"))
                                for i in range(0, len(family)):
                                    zfc = ""
                                    for j in range(0, len(family[i])):
                                        zfc = zfc + "\t" + str(family[i][j])
                                    print(i, zfc)
                                    print("".center(50, "-"))
                                break
                            elif find == "2":
                                print("".center(50, "-"))
                                for i in range(0, len(family)):
                                    zfc = ""
                                    for j in range(0, len(family[i])):
                                        zfc = zfc + "\t" + str(family[i][j])
                                    print(zfc)
                                    print("".center(50, "-"))
                                break
                            elif find == "3":
                                print("".center(50, "-"))
                                for i in range(0, len(family)):
                                    zfc = ""
                                    family[i][0], family[i][1] = family[i][1], family[i][0]
                                    for j in range(0, len(family[i])):
                                        zfc = zfc + "\t" + str(family[i][j])
                                    print(zfc)
                                    print("".center(50, "-"))
                                break
                            elif find == "4":
                                print("".center(50, "-"))
                                for i in range(0, len(family)):
                                    zfc = ""
                                    family[i][0], family[i][2] = family[i][2], family[i][0]
                                    for j in range(0, len(family[i])):
                                        zfc = zfc + "\t" + str(family[i][j])
                                    print(zfc)
                                    print("".center(50, "-"))
                                break
                            elif find == "5":
                                print("".center(50, "-"))
                                for i in range(0, len(family)):
                                    zfc = ""
                                    family[i][0], family[i][3] = family[i][3], family[i][0]
                                    for j in range(0, len(family[i])):
                                        zfc = zfc + "\t" + str(family[i][j])
                                    print(zfc)
                                    print("".center(50, "-"))
                                break
                            else:
                                print("输入错误，请重新输入：")
                                continue
                    else:
                        print("输入错误，请重新输入：")
                        continue
